//
//  LoanRecordtypeTwoTableViewCell.m
//  51易借
//
//  Created by apple on 2017/9/19.
//  Copyright © 2017年 张睿. All rights reserved.
//

#import "LoanRecordtypeTwoTableViewCell.h"

@implementation LoanRecordtypeTwoTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    [self setSelectionStyle:NO];
    [self.labels enumerateObjectsUsingBlock:^(UILabel*  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        obj.font = [UIFont systemFontOfSize:15*SCREENH6];
    }];
    [self.stateBtn.titleLabel setFont:[UIFont systemFontOfSize:10*SCREENH6]];
    [self.operateBtn.titleLabel setFont:[UIFont systemFontOfSize:14*SCREENH6]];

}

- (IBAction)pushToRepay:(id)sender {
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"pushToRepay" object:nil];
}


-(void)setModel:(LoanModel *)model
{
    _model = model;
    
    self.amountLabel.text = [NSString stringWithFormat:@"￥%.2f元",[model.borrowAmount floatValue]];
//    self.loanTimeLabel.text = [Lahelper formattedTimeFromTimeInterval:[model.loanTime longLongValue]];
    self.loanTimeLabel.text = [Lahelper formattedTimeFromTimeInterval:[model.overdueTime longLongValue]];
    self.repayTimeLabel.text = [Lahelper formattedTimeFromTimeInterval:[model.applyTime longLongValue]];
    self.repayAmountLabel.text = [NSString stringWithFormat:@"￥%.2f元",[model.repayTotalAmount floatValue]];
    //综合显示状态（1.审核中 2.审核未通过 3.审核打款中 4.待还款 5.已逾期 6.还款处理中 7.已还款 8.已逾期还款）
    switch ([model.unionStatus intValue]) {
        case 1:
        {
            [self.stateBtn setTitle:@"审核中/打款中" forState:UIControlStateNormal];
            [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"审核中-打款中"] forState:UIControlStateNormal];
        }
            break;
        case 2:
        {
            [self.stateBtn setTitle:@"审核未通过" forState:UIControlStateNormal];
            [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"审核未通过"] forState:UIControlStateNormal];
        }
            break;
        case 3:
        {
            [self.stateBtn setTitle:@"审核打款中" forState:UIControlStateNormal];
            [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"审核打款中"] forState:UIControlStateNormal];
        }
            break;
        case 4:
        {
            [self.stateBtn setTitle:@"待还款" forState:UIControlStateNormal];
            [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"待还款"] forState:UIControlStateNormal];
            [self.operateBtn setTitle:@"立即还款" forState:UIControlStateNormal];

        }
            break;
        case 5:
        {
            [self.stateBtn setTitle:@"已逾期" forState:UIControlStateNormal];
            [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"已逾期"] forState:UIControlStateNormal];
            [self.operateBtn setTitle:@"立即还款" forState:UIControlStateNormal];

        }
            break;
        case 6:
        {
            [self.stateBtn setTitle:@"还款处理中" forState:UIControlStateNormal];
            [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"还款处理中"] forState:UIControlStateNormal];
            [self.operateBtn setTitle:@"自动扣款/\n主动扣款" forState:UIControlStateNormal];

        }
            break;
        case 7:
        {
            [self.stateBtn setTitle:@"已还款" forState:UIControlStateNormal];
            [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"已还款"] forState:UIControlStateNormal];
        }
            break;
        case 8:
        {
            [self.stateBtn setTitle:@"已逾期还款" forState:UIControlStateNormal];
            [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"已逾期还款"] forState:UIControlStateNormal];
        }
            break;
        default:
            break;
    }
    
}

@end
